package com.yjd.msg.comm.enums;

import com.yjd.comm.util.FrameUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by yjd-wap on 2018/1/19.
 */
public enum  MsgTypeEnum {
    ORDER_MSG_DEMO("ORDER_MSG_DEMO","用户贷款申请订单demo"),
    LOAN_APPLY_MSG("LOAN_APPLY_MSG","贷款申请"),
    LOAN_APPLY_REPLY_MSG("LOAN_APPLY_REPLY_MSG","贷款申请回调"),
    ORDER_REPAYMENT_STATUS_UPDATE("ORDER_REPAYMENT_STATUS_UPDATE","用户还款状态更新");

    private String code;
    private String desc;

    private MsgTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public  static MsgTypeEnum getMsgTypeEnum(String code)throws Exception{
        MsgTypeEnum msgTypeEnum = null;
        for(MsgTypeEnum msgTypeEnum1 : MsgTypeEnum.values()){
            if(msgTypeEnum1.getCode().equals(code)){
                msgTypeEnum = msgTypeEnum1;
                break;
            }
        }
        return msgTypeEnum;
    }

    public static List<Map> getMsgTypeList()throws Exception{
        List<Map> typeList = new ArrayList<>();
        for(MsgTypeEnum msgTypeEnum1 : MsgTypeEnum.values()){
            typeList.add(FrameUtil.newHashMap("code",msgTypeEnum1.getCode(),"desc",msgTypeEnum1.getDesc()));
        }
        return  typeList;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
